<?php
class test extends Pay {

    function _payto() {
        foreach ($this->items as $v) {
            $amount += $v['amount'];
            $body .= "{$v['iname']} x {$v['amount']} | ";
        }

        //标题
        $pd['subject'] = '乐铺'.$this->id.'号订单';
        //描述
        //$pd['body'] = substr(str_replace($this->badwords, '**', $body),0,50);
        $pd['body'] = $pd['subject'];

        //外部订单号
        $pd['out_trade_no'] = $this->id;
        //单价
        $pd['price'] = $this->data['sumfee'];
        //折扣
        if ($this->data['adjustfee']!='0.00') $pd['discount'] = $this->data['adjustfee'];
        //数量
        $pd['quantity'] = 1;
        //支付类型
        $pd['payment_type'] = 1; //商品购买

        //物流支付类型
        $pd['logistics_payment'] = 'BUYER_PAY'; //买家付款
        //物流费用
        if ($this->data['postfee']) $pd['logistics_fee'] = $this->data['postfee'];
        //物流类型
        $pd['logistics_type'] = ($this->data['postfee'] > 6 ? ($this->data['postfee'] == 25 ? "EMS" : "EXPRESS") : "POST");
        //收货人姓名
        $pd['receive_name'] = $this->data['linkman'];
        //收货人地址
        $pd['receive_address'] = $this->data['address'];
        //邮编
        $pd['receive_zip'] = $this->data['zipcode'];
        //电话或手机
        if (preg_match('/^13[0-9]{9}$/', $this->data['tel']))
            $pd['receive_mobile'] = $this->data['tel'];
        else
            $pd['receive_phone'] = $this->data['tel'];

        //卖家email
        $pd['seller_email'] = $this->alipayid;
        //留言
        //if ($this->data['memo']) $pd['buyer_msg'] = $this->data['memo'];

        ksort($pd);

        foreach ($pd as $k=>$v) $md5str[] = "$k=$v";
        $md5str = join('&', $md5str).$this->scode;

        $sign = md5($md5str);


        $url = '/shell/testpayresult.php?id='. $this->id .'&fee='. ($this->data['sumfee']+$this->data['adjustfee']+$this->data['postfee']);

        return $url;
    }

    function _payresult() {
        $result = array();

        $this->id = $this->request['id'];
        $result['code']['payResult'] = 1;
        $result['data'] = $this->request;
        $result['code']['payResult'] = 1;

        //实付金额
        $result['pay'] = (float)$result['data']['fee'];

        return $result;
    }

}
?>
